package com.hoyue.service;

import com.hoyue.bean.Character;
import com.hoyue.dao.CharacterDao;
import com.hoyue.dao.impl.CharacterDaoImpl;

import java.sql.SQLException;
import java.util.List;

public class CharacterService {
    CharacterDao characterDao = new CharacterDaoImpl();

    public void addChar(Character character) {
        try {
            characterDao.addChar(character);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public void deleteChar(int id) {
        try {
            characterDao.deleteChar(id);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public void updateChar(Character character) {
        try {
            characterDao.updateChar(character);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public Character getCharacterById(String id) {
        try {
            return characterDao.getCharacterById(id);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
    public List<Character> getAllChar() {
        try {
            return characterDao.getAllChar();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    public String getAddressById(int id) {
        try {
            return characterDao.getAddressById(id);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

}
